package com.simba.server.commands;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.simba.common.command.ICommand;
import com.simba.server.commands.impl.del.*;
import com.simba.server.commands.impl.fetch.*;
import com.simba.server.commands.impl.record.*;
import com.simba.server.commands.impl.update.*;
import com.simba.server.commands.impl.web.*;
import com.simba.server.components.data.*;

public class CommandCreator
{
	private static class CommandCreatorHolder
	{
		private static CommandCreator INSTANCE = new CommandCreator();
	}

	public static CommandCreator getInstance()
	{
		return CommandCreatorHolder.INSTANCE;
	}

	private CommandCreator()
	{
	}

	@SuppressWarnings("unchecked")
	public ICommand createCommand(String cmdName, Object paramsObj)
	{
		ICommand command = null;

		switch (cmdName)
		{
			case RecordPacketOffCmd.NAME:
				command = new RecordPacketOffCmd((SortInfo) paramsObj);
				break;
			case RecordPacketOnCmd.NAME:
				command = new RecordPacketOnCmd((SortInfo) paramsObj);
				break;
			case RecordBoxPackCmd.NAME:
				command = new RecordBoxPackCmd((SlotInfo) paramsObj);
				break;
			case RecordMachineOpsCmd.NAME:
				command = new RecordMachineOpsCmd((MachineOps) paramsObj);
				break;
			case RecordPacketOffHistoryCmd.NAME:
				command = new RecordPacketOffHistoryCmd((Integer) paramsObj);
				break;
			case RecordSlotPackHistoryCmd.NAME:
				command = new RecordSlotPackHistoryCmd((Integer) paramsObj);
				break;
			case WebBoxInfoCmd.NAME:
				command = new WebBoxInfoCmd((SlotInfo) paramsObj);
				break;
			case FetchTrashSlotsCmd.NAME:
				command = new FetchTrashSlotsCmd((Map<Integer, List<Integer>>) paramsObj);
				break;
			case FetchInfoByBarcodeCmd.NAME:
				command = new FetchInfoByBarcodeCmd((BarcodeInfo) paramsObj);
				break;
			case FetchPacketOffByNoUploadCmd.NAME:
				command = new FetchPacketOffByNoUploadCmd((SortInfo) paramsObj);
				break;
			case FetchPacketByBoxCodeCmd.NAME:
				command = new FetchPacketByBoxCodeCmd((BoxInfo) paramsObj);
				break;
			case FetchBoxPackCmd.NAME:
				command = new FetchBoxPackCmd((BoxInfo) paramsObj);
				break;
			case FetchSlotInfoCmd.NAME:
				command = new FetchSlotInfoCmd((List<SlotInfo>) paramsObj);
				break;
			case FetchBasicConfigCmd.NAME:
				command = new FetchBasicConfigCmd((HashMap<String, String>) paramsObj);
				break;
			case FetchPacketOffByNoSyncCmd.NAME:
				command = new FetchPacketOffByNoSyncCmd((List<Integer>) paramsObj);
				break;
			case FetchSlotPackByNoSyncCmd.NAME:
				command = new FetchSlotPackByNoSyncCmd((List<Integer>) paramsObj);
				break;
			case FetchTestSortInfoCmd.NAME:
				command = new FetchTestSortInfoCmd((SortInfo)paramsObj);
				break;
			case RenewBoxPackCmd.NAME:
				command = new RenewBoxPackCmd((BoxInfo) paramsObj);
				break;
			case RenewSortResultCmd.NAME:
				command = new RenewSortResultCmd((SortInfo) paramsObj);
				break;
			case RenewBasicConfigCmd.NAME:
				command = new RenewBasicConfigCmd((BasicConfig) paramsObj);
				break;
			case RenewPacketOffSyncCmd.NAME:
				command = new RenewPacketOffSyncCmd((List<Integer>) paramsObj);
				break;
			case RenewSlotPackSyncCmd.NAME:
				command = new RenewSlotPackSyncCmd((List<Integer>) paramsObj);
				break;
			case RenewBarcodeInfoExpiredCmd.NAME:
				command = new RenewBarcodeInfoExpiredCmd((String) paramsObj);
				break;
			case DelPackageOffHistoryCmd.NAME:
				command = new DelPackageOffHistoryCmd((DeleteData) paramsObj);
				break;
			case DelPacketOffCmd.NAME:
				command = new DelPacketOffCmd((DeleteData) paramsObj);
				break;
			case DelPacketOnCmd.NAME:
				command = new DelPacketOnCmd((DeleteData) paramsObj);
				break;
			case DelSlotPackCmd.NAME:
				command = new DelSlotPackCmd((DeleteData) paramsObj);
				break;
			case DelSlotPackHistoryCmd.NAME:
				command = new DelSlotPackHistoryCmd((DeleteData) paramsObj);
				break;

			case TruncateTableCmd.NAME:
				command = new TruncateTableCmd((String) paramsObj);
				break;
			case WebBFJStatusCmd.NAME:
				command = new WebBFJStatusCmd((MachineRunInfo) paramsObj);
				break;
			case WebOBRStateCmd.NAME:
				command = new WebOBRStateCmd((String) paramsObj);
				break;
			case WebPacketOffCmd.NAME:
				command = new WebPacketOffCmd((SortInfo) paramsObj);
				break;
			case WebPacketScanCmd.NAME:
				command = new WebPacketScanCmd((SortInfo) paramsObj);
				break;
			case WebRecycleSlotStateCmd.NAME:
				command = new WebRecycleSlotStateCmd((SortInfo) paramsObj);
				break;
			case WebSlotStatusCmd.NAME:
				command = new WebSlotStatusCmd((SlotInfo) paramsObj);
				break;
			case WebSortInfoCmd.NAME:
				command = new WebSortInfoCmd((SortInfo) paramsObj);
				break;
			case WebPackSlotCmd.NAME:
				command = new WebPackSlotCmd((BoxInfo) paramsObj);
				break;
			case WebPowerCmd.NAME:
				command = new WebPowerCmd();
				break;
			case WebLockSlotsCmd.NAME:
				command = new WebLockSlotsCmd((SlotInfo[]) paramsObj);
				break;
			case FetchMachineInfoCmd.NAME:
				command = new FetchMachineInfoCmd((MachineRunInfo) paramsObj);
				break;
			case FetchPackageOffCountCmd.NAME:
				command = new FetchPackageOffCountCmd((MachineRunInfo) paramsObj);
				break;
			case RecordMachineInfoCmd.NAME:
				command = new RecordMachineInfoCmd((Map<String, Object>) paramsObj);
				break;
			case RecordMachineStatusLocalCmd.NAME:
				command = new RecordMachineStatusLocalCmd((Map<String, Object>) paramsObj);
				break;
			case RenewMachineInfoCmd.NAME:
				command = new RenewMachineInfoCmd((Map<String, Object>) paramsObj);
				break;
			case RecordPacketOffReportCmd.NAME:
				command = new RecordPacketOffReportCmd((SortInfo) paramsObj);
				break;
			case DelPacketOffReportCmd.NAME:
				command = new DelPacketOffReportCmd((DeleteData)paramsObj);
				break;
			case FetchPrinterInfoCmd.NAME:
				command = new FetchPrinterInfoCmd((List<PrinterInfo>) paramsObj);
				break;
			default:
				break;
		}
		return command;
	}
}
